package com.principle.demeter;

import java.util.ArrayList;
import java.util.List;

//客户端
public class Demeter {
    public static void main(String[] args) {
        SchoolManager schoolManager = new SchoolManager();
        schoolManager.printAllEmployee(new CollegeManager());
    }
}
//学校总部员工
class Employee{
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
//学院的员工类
class CollegeEmployee{
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
//管理学院员工的管理类
class CollegeManager{
    public List<CollegeEmployee> getAllEmployee(){
        List<CollegeEmployee> list=new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            CollegeEmployee emp = new CollegeEmployee();
            emp.setId("学院员工id="+i);
            list.add(emp);
        }
        return list;
    }
    public void printEmployee(){
        List<CollegeEmployee> list1 = this.getAllEmployee();
        System.out.println("-----------分公司员工------------");
        for (CollegeEmployee collegeEmployee : list1) {
            System.out.println(collegeEmployee.getId());
        }
    }
}
//学校管理类
class SchoolManager{
    public List<Employee> getAllEmployee(){
        List<Employee> list=new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Employee employee = new Employee();
            employee.setId("学院员工id="+i);
            list.add(employee);
        }
        return list;
    }
    void printAllEmployee(CollegeManager sub){
        sub.printEmployee();

        List<Employee> allEmployee = this.getAllEmployee();
        for (Employee employee : allEmployee) {
            System.out.println(employee.getId());
        }
    }
}